﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using HGZP.BLL;
using HGZP.Model;

namespace SZCB.admin.FoodManager
{
    public partial class FoodSubstance : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                ViewState["wheresql"] = "";
                GetContentCount();
                BindContentData();

            }

        }

        #region 绑定食品大类信息
        /// <summary>
        /// 绑定大类信息
        /// </summary>
        private void BindFoodClass()
        {
            CSubstanceBLL myCSubstanceBLL = new CSubstanceBLL();
            RptData.DataSource = myCSubstanceBLL.F01_SelectAll();
            RptData.DataBind();


        }
        #endregion

        #region 绑定内容表单()
        private void GetContentCount()
        {
            string sql = " ";
            if (ViewState["wheresql"] != null)
                sql += ViewState["wheresql"].ToString();
            CSubstanceBLL myCSubstanceBLL = new CSubstanceBLL();
            returnDataPager.RecordCount = myCSubstanceBLL.F09_GetCount(sql);
        }
        private void BindContentData()
        {
            string sql = " ";
            if (ViewState["wheresql"] != null)
                sql += ViewState["wheresql"].ToString();
            CSubstanceBLL myCSubstanceBLL = new CSubstanceBLL();
            RptData.DataSource = myCSubstanceBLL.F08_SelectColumnHaveWhereOrder_OnePage(returnDataPager.StartRecordIndex - 1, returnDataPager.PageSize, "*", sql, myCSubstanceBLL.dCreateDate + " DESC");
            RptData.DataBind();
        }
        protected void ReturnDataPagerPageChanged(object sender, EventArgs e)
        {
            BindContentData();
        }
        #endregion

        #region 内容信息批量删除
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lbtnDelete_Click(object sender, EventArgs e)
        {
            /*string strBenefitsBook = string.Empty;
            for (int i = 0; i < RptData.Items.Count; i++)
            {
                CheckBox checkBox = (CheckBox)RptData.Items[i].FindControl("cbCheck");
                Literal literal = (Literal)RptData.Items[i].FindControl("ltrsGuid");
                if (checkBox.Checked)
                {
                    if (!string.IsNullOrEmpty(literal.Text))
                    {
                        strBenefitsBook += literal.Text + ",";
                    }
                }
            }
            if (string.IsNullOrEmpty(strBenefitsBook))
            {
                Public.globalErrorString = "请选择你要设置优惠的图书！";
                Tip_Web.Tip();
                return;
            }
            string[] benefitsBooks = strBenefitsBook.Split(',');
            var contentBll = new CWorkBookContentBLL();
            int iSuccess = benefitsBooks.Where(benefitsBook => !string.IsNullOrEmpty(benefitsBook)).Count(contentBll.F_Delete);
            Public.globalErrorString = "成功删除资源内容" + iSuccess + "个";
            Tip_Web.Tip();
            GetContentCount();
            BindContentData();*/
        }
        #endregion

        #region 视频信息批量删除
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lbtnVideoDel_Click(object sender, EventArgs e)
        {
            /*  string strBenefitsBook = string.Empty;
              for (int i = 0; i < RptVideo.Items.Count; i++)
              {
                  CheckBox checkBox = (CheckBox)RptVideo.Items[i].FindControl("cbCheck");
                  Literal literal = (Literal)RptVideo.Items[i].FindControl("ltrsGuid");
                  if (checkBox.Checked)
                  {
                      if (!string.IsNullOrEmpty(literal.Text))
                      {
                          strBenefitsBook += literal.Text + ",";
                      }
                  }
              }
              if (string.IsNullOrEmpty(strBenefitsBook))
              {
                  Public.globalErrorString = "请选择你要设置优惠的图书！";
                  Tip_Web.Tip();
                  return;
              }
              string[] benefitsBooks = strBenefitsBook.Split(',');
              var videoBll = new CWorkBookContentVideoBLL();
              int iSuccess = benefitsBooks.Where(benefitsBook => !string.IsNullOrEmpty(benefitsBook)).Count(videoBll.F_Delete);
              Public.globalErrorString = "成功删除资源内容" + iSuccess + "个";
              Tip_Web.Tip();
              GetVideoCount();
              BindVideoData();*/
        }
        #endregion

    }
}